﻿namespace com.stifel.BranchMgmt
{
    using System.Linq;

    using com.stifel.BranchMgmtDao;
    using com.stifel.Extensions.SymbolExtensions;
    using com.stifel.SharePoint;

    using Microsoft.SharePoint;

    public class StifelSunsetBranchInfoConfiguration_Definition : StifelBaseDefinition
    {
        #region Fields

        const string SITECOLUMNS = "Stifel-SunsetBranchInfoConfiguration.xml";

        #endregion Fields

        #region Constructors

        public StifelSunsetBranchInfoConfiguration_Definition( SPFeatureReceiverProperties properties )
            : base(properties)
        {
        }

        ~StifelSunsetBranchInfoConfiguration_Definition( )
        {
            Dispose( false );
        }

        #endregion Constructors

        #region Methods

        public override void Create( )
        {
            base.Create( );
            CreateSiteColumns( GetFieldDefinitionsAsXml( SITECOLUMNS ) );
            CreateContentType( getContentTypeDefn( ) );
            CreateList( getListDefn( ) );
            //                        loadList( );
        }

        public override void Delete( )
        {
            base.Delete( );
            DeleteList( getListDefn( ), false );
            DeleteContentType( getContentTypeDefn( ) );
            DeleteSiteColumns( GetFieldDefinitionsAsXml( SITECOLUMNS ) );
        }

        ContentTypeDefn getContentTypeDefn( )
        {
            StifelSunsetBranchInfoConfiguration c = null;
            return new ContentTypeDefn
            {
                Name = Item.GetContentTypeName<StifelSunsetBranchInfoConfiguration>( ),
                ContentTypeId = Item.GetContentTypeId<StifelSunsetBranchInfoConfiguration>( ),
                WebLevel = false,
                Group = "Stifel",
                Description = "Describes the configuration used when sunsetting branch information.",
                Fields = new FieldDefn[ ] {
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.ActiveSunsetConfiguration))
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BeginNotificationNDaysBeforeBranchLeaseExpiration)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.RepeatNotificationEveryNDaysUntilBranchLeaseResolution)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.SiteURLForTheBranchLeaseInformation)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.SiteURLForTheBranchLeaseNotification)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchLeaseExpirationNotificationTitle)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchLeaseExpirationNotificationTemplate)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchLeaseGroupId)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchLeaseSendEmail))
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BeginNotificationNDaysBeforeBranchTelMaintenanceContractExpiration)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.RepeatNotificationEveryNDaysUntilBranchTelMaintenanceContractResolution)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.SiteURLForTheBranchTelMaintenanceContractInformation)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.SiteURLForTheBranchTelMaintenanceContractNotification)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchTelMaintenanceContractExpirationNotificationTitle)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchTelMaintenanceContractExpirationNotificationTemplate)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchTelMaintenanceContractGroupId)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchTelMaintenanceContractSendEmail))
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BeginNotificationNDaysBeforeBranchHardwareScheduledMaintenance)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.RepeatNotificationEveryNDaysUntilScheduleBranchHardwareMaintenanceCompleted)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.SiteURLForTheBranchHardwareMaintenanceInformation)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.SiteURLForTheBranchHardwareMaintenanceNotification)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchHardwareMaintenanceScheduledNotificationTitle)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchHardwareMaintenanceScheduledNotificationTemplate)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchHardwareMaintenanceGroupId)),
                        Required=true
                    },
                    new FieldDefn{
                        Name=Item.GetColumnName<StifelSunsetBranchInfoConfiguration>(c.GetPropertySymbol(a=>a.BranchHardwareMaintenanceSendEmail))
                    },
                }.Distinct( ).ToList( )
            };
        }

        ListDefn getListDefn( )
        {
            return new ListDefn
            {
                RootFolderName = StifelSunsetBranchInfoConfigurationDao.ListName,
                Title = "Stifel Sunset Branch Info Configuration",
                Description = "Contains configuration to control the sunset of branch information.",
                ContentTypes = new string[ ] {
                    Item.GetContentTypeName<StifelSunsetBranchInfoConfiguration>()
                }.ToList( )
            };
        }

        void loadList( )
        {
        }

        #endregion Methods
    }
}